//
//  WCTConfig.h
//  WeChatTool
//
//  Created by TerryChe on 2016/12/2.
//  Copyright © 2016年 TerryChe. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "WCTLogService.h"
//#import "DBHelper.h"
//#import "FMDB.h"
#import "DBHelper2.h"
#import "OPHNetwork.h"

#define formatEmptyString(str)  (str == nil ? @"" : str)
#define log(format,...) ([[WCTLogService sharedInstance] writeLog:[NSString stringWithFormat:format, ##__VA_ARGS__, nil]]);

static NSString* str_documents = @"Documents";
static NSString* str_localInfo = @"LocalInfo.lst";
static NSString* str_mmsetting = @"mmsetting.archive";
static NSString* str_db_mm = @"DB/MM.sqlite";
static NSString* str_db_wcdb_contact = @"DB/WCDB_Contact.sqlite";
static NSString* str_contactlabel = @"contactlabel.list";
static NSString* str_library_emoticonAutoClean =@"Library/WechatPrivate/emoticonAutoClean";
static NSString* str_library_emoticonPIC = @"Library/WechatPrivate/emoticonPIC";

#if TARGET_IPHONE_SIMULATOR//模拟器
#define str_wct_application [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
#define str_wct_dir [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
#elif TARGET_OS_IPHONE//真机
#define str_wct_application ([[UIDevice currentDevice].systemVersion doubleValue] < 8.0 ? @"/var/mobile/Applications/" : @"/var/mobile/Containers/Data/Application/");
static NSString* str_wct_dir = @"/var/mobile/Documents/WeChatTool/";
#endif

static NSString* str_wct_config = @"config.plist";
static NSString* str_wct_user = @"user.plist";
static NSString* str_wct_friend = @"friend.plist";
static NSString* str_wct_friend_data = @"friendData.plist";
static NSString* str_wct_chatroom = @"chatroom.plist";
static NSString* str_wct_chatmsg = @"chatmsg.plist";
static NSString* str_wct_img = @"img.plist";
static NSString* str_wct_updatedeb = @"update.deb";
static NSString* str_wct_log = @"wct.log";
static NSString* str_wct_logList = @"logList.plist";
static NSString* str_wct_localInfo = @"LocalInfo.plist";
static NSString* str_wct_mmsetting = @"mmsetting.plist";


static NSString* str_wct_autoinstall = @"/var/root/Media/Cydia/AutoInstall/update.deb";
static NSString* str_wct_install = @"/var/mobile/Downloads/update.deb";

static int WCT_LabelType = 9999;

static int wct_version = 43;
static NSString* wct_version_name = @"1.4.3";

//#define wct_version (int)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
//#define wct_version_name [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

@interface WCTConfig : NSObject

@property (nonatomic, strong) NSString* address;

@property (nonatomic, strong) NSString* appKey;

@property (nonatomic, strong) NSString* appID;

@property (nonatomic, strong) NSString* nonce;

@property (nonatomic, assign) int sleep;

@property (nonatomic, assign) int batchCount;

@property (nonatomic, strong) NSString* token;

@property (nonatomic, assign) UInt64 expiresIn;

@property (nonatomic, assign) UInt64 beginDate;

@property (nonatomic, assign) double appStartTime;

@property (nonatomic, strong) NSMutableDictionary *configDic;
@property (nonatomic, strong) NSMutableDictionary<NSString*, NSDictionary*>* cacheFriend;
@property (nonatomic, strong) NSMutableArray<NSString*>* cacheChatRoom;
@property (nonatomic, strong) NSMutableDictionary* cacheChatMsg;
@property (nonatomic, strong) NSMutableArray* cacheImg;
@property (nonatomic, strong) NSMutableArray* cachePayMsgid;

+(instancetype)sharedInstance;

-(BOOL)hasConfig;

-(void)updateToken:(NSString *)token ExpiresIn:(UInt64)expiresIn;

-(void)updateAppStartTime;

//sha1加密方式
- (NSString *) sha1:(NSString *)input;

- (NSString *) sha1WithData:(NSData *)input;

//md5加密方式
- (NSString *) md5:(NSString *) input;

@end
